package com.kafkacode.config;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Map;

public class CustomerProducerInterceptor implements ProducerInterceptor<String,Object> {
    /**
     * 发送消息之前，自动调用本方法（拦截器）
     * @param producerRecord
     * @return
     */
    @Override
    public ProducerRecord<String,Object> onSend(ProducerRecord producerRecord) {
        System.out.println("producerRecord = " + producerRecord.toString());
        return producerRecord;
    }

    @Override
    public void onAcknowledgement(RecordMetadata recordMetadata, Exception e) {

    }

    @Override
    public void close() {

    }

    @Override
    public void configure(Map<String, ?> map) {

    }
}
